<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<!--      <el-form-item label="id" prop="id">-->
<!--        <el-input-->
<!--          v-model="queryParams.id"-->
<!--          placeholder="请输入id"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="店/厂端" prop="inventoryType">
        <el-input
          v-model="queryParams.inventoryType"
          placeholder="请输入店端/厂端的库存"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="零件来源" prop="partSource">
        <el-select v-model="queryParams.partSource" placeholder="请选择零件来源" clearable>
          <el-option
            v-for="dict in dict.type.part_source"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="零件编码" prop="partNo">
        <el-input
          v-model="queryParams.partNo"
          placeholder="请输入零件编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="零件名称" prop="partName">
        <el-input
          v-model="queryParams.partName"
          placeholder="请输入零件名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="零件类型" prop="partType">
        <el-select v-model="queryParams.partType" placeholder="请选择零件类型" clearable>
          <el-option
            v-for="dict in dict.type.part_name"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="零件状态" prop="partStatus">
        <el-select v-model="queryParams.partStatus" placeholder="请选择零件状态" clearable>
          <el-option
            v-for="dict in dict.type.part_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="网点单价" prop="outletPrice">
        <el-input
          v-model="queryParams.outletPrice"
          placeholder="请输入网点单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="零售单价" prop="salePrice">
        <el-input
          v-model="queryParams.salePrice"
          placeholder="请输入零售单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="采购单价" prop="purchasePrice">
        <el-input
          v-model="queryParams.purchasePrice"
          placeholder="请输入采购单价(子公司向总部采购价）"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生效日期" prop="effectiveDate">
        <el-date-picker clearable
          v-model="queryParams.effectiveDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择生效日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="截止日期" prop="expirationDate">
        <el-date-picker clearable
          v-model="queryParams.expirationDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择截止日期">
        </el-date-picker>
      </el-form-item>
<!--      <el-form-item label="裸件长mm" prop="grossLength">-->
<!--        <el-input-->
<!--          v-model="queryParams.grossLength"-->
<!--          placeholder="请输入裸件长mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="裸件宽mm" prop="grossWidth">-->
<!--        <el-input-->
<!--          v-model="queryParams.grossWidth"-->
<!--          placeholder="请输入裸件宽mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="裸件高mm" prop="grossHeight">-->
<!--        <el-input-->
<!--          v-model="queryParams.grossHeight"-->
<!--          placeholder="请输入裸件高mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="包装长mm" prop="packageLength">-->
<!--        <el-input-->
<!--          v-model="queryParams.packageLength"-->
<!--          placeholder="请输入包装长mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="包装宽mm" prop="packageWidth">-->
<!--        <el-input-->
<!--          v-model="queryParams.packageWidth"-->
<!--          placeholder="请输入包装宽mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="包装高mm" prop="packageHeight">-->
<!--        <el-input-->
<!--          v-model="queryParams.packageHeight"-->
<!--          placeholder="请输入包装高mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="存放长mm" prop="storeLength">-->
<!--        <el-input-->
<!--          v-model="queryParams.storeLength"-->
<!--          placeholder="请输入存放长mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="存放宽mm" prop="storeWidth">-->
<!--        <el-input-->
<!--          v-model="queryParams.storeWidth"-->
<!--          placeholder="请输入存放宽mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="存放高mm" prop="storeHeight">-->
<!--        <el-input-->
<!--          v-model="queryParams.storeHeight"-->
<!--          placeholder="请输入存放高mm"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="裸件重量g" prop="grossWeight">-->
<!--        <el-input-->
<!--          v-model="queryParams.grossWeight"-->
<!--          placeholder="请输入裸件重量g"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="包装重量" prop="packageWeight">
        <el-input
          v-model="queryParams.packageWeight"
          placeholder="请输入包装后重量g"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="体积" prop="volume">
        <el-input
          v-model="queryParams.volume"
          placeholder="请输入体积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否销售" prop="isSale">
        <el-select v-model="queryParams.isSale" placeholder="请选择是否可销售" clearable>
          <el-option
            v-for="dict in dict.type.no_and_yes"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否采购" prop="isPurchase">
        <el-select v-model="queryParams.isPurchase" placeholder="请选择是否可采购" clearable>
          <el-option
            v-for="dict in dict.type.no_and_yes"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否排放" prop="isEmission">
        <el-select v-model="queryParams.isEmission" placeholder="请选择是否排放件" clearable>
          <el-option
            v-for="dict in dict.type.no_and_yes"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否安全" prop="isSafety">
        <el-select v-model="queryParams.isSafety" placeholder="请选择是否安全件" clearable>
          <el-option
            v-for="dict in dict.type.no_and_yes"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否防盗" prop="isAntiTheft">
        <el-select v-model="queryParams.isAntiTheft" placeholder="请选择是否防盗件" clearable>
          <el-option
            v-for="dict in dict.type.no_and_yes"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="是否认证" prop="isCertified">
        <el-select v-model="queryParams.isCertified" placeholder="请选择是否认证件" clearable>
          <el-option
            v-for="dict in dict.type.no_and_yes"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="航空禁运" prop="isAirEmbargo">
        <el-select v-model="queryParams.isAirEmbargo" placeholder="请选择是否航空禁运件" clearable>
          <el-option
            v-for="dict in dict.type.no_and_yes"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
<!--      <el-form-item label="厂端id" prop="factoryId">-->
<!--        <el-input-->
<!--          v-model="queryParams.factoryId"-->
<!--          placeholder="请输入厂端id"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="厂端名称" prop="factoryName">
        <el-input
          v-model="queryParams.factoryName"
          placeholder="请输入厂端名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="经销商id" prop="dealerId">-->
<!--        <el-input-->
<!--          v-model="queryParams.dealerId"-->
<!--          placeholder="请输入经销商id"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="经销商名" prop="dealerName">
        <el-input
          v-model="queryParams.dealerName"
          placeholder="请输入销售店名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="经销商的零件最后一次出库时间" prop="dealerLastShipmentTime">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.dealerLastShipmentTime"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择经销商的零件最后一次出库时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="经销商的零件最后一次入库时间" prop="dealerLastStorageTime">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.dealerLastStorageTime"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择经销商的零件最后一次入库时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="厂端的零件最后一次出库时间" prop="factoryLastShipmentTime">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.factoryLastShipmentTime"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择厂端的零件最后一次出库时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="厂端的零件最后一次入库时间" prop="factoryLastStorageTime">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.factoryLastStorageTime"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择厂端的零件最后一次入库时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['part:inventory:add']"
          v-if="this.$store.state.user.name.charAt(0)=='C'"
        >新增</el-button>
      </el-col>
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="success"-->
<!--          plain-->
<!--          icon="el-icon-edit"-->
<!--          size="mini"-->
<!--          :disabled="single"-->
<!--          @click="handleUpdate"-->
<!--          v-hasPermi="['part:inventory:edit']"-->
<!--        >修改</el-button>-->
<!--      </el-col>-->
<!--      <el-col :span="1.5">-->
<!--        <el-button-->
<!--          type="danger"-->
<!--          plain-->
<!--          icon="el-icon-delete"-->
<!--          size="mini"-->
<!--          :disabled="multiple"-->
<!--          @click="handleDelete"-->
<!--          v-hasPermi="['part:inventory:remove']"-->
<!--        >删除</el-button>-->
<!--      </el-col>-->
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['part:inventory:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="inventoryList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" v-if="false"/>
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="店端/厂端的库存" align="center" prop="inventoryType" />
      <el-table-column label="零件来源" align="center" prop="partSource">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.part_source" :value="scope.row.partSource"/>
        </template>
      </el-table-column>
      <el-table-column label="零件编码" align="center" prop="partNo" />
      <el-table-column label="零件名称" align="center" prop="partName" />
      <el-table-column label="零件类型" align="center" prop="partType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.part_name" :value="scope.row.partType"/>
        </template>
      </el-table-column>
      <el-table-column label="零件状态" align="center" prop="partStatus">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.part_status" :value="scope.row.partStatus"/>
        </template>
      </el-table-column>
      <el-table-column label="网点单价" align="center" prop="outletPrice" />
      <el-table-column label="零售单价" align="center" prop="salePrice" />
      <el-table-column label="采购单价" align="center" prop="purchasePrice" />
      <el-table-column label="生效日期" align="center" prop="effectiveDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.effectiveDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="截止日期" align="center" prop="expirationDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.expirationDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="裸件长mm" align="center" prop="grossLength" />
      <el-table-column label="裸件宽mm" align="center" prop="grossWidth" />
      <el-table-column label="裸件高mm" align="center" prop="grossHeight" />
      <el-table-column label="包装长mm" align="center" prop="packageLength" />
      <el-table-column label="包装宽mm" align="center" prop="packageWidth" />
      <el-table-column label="包装高mm" align="center" prop="packageHeight" />
      <el-table-column label="存放长mm" align="center" prop="storeLength" />
      <el-table-column label="存放宽mm" align="center" prop="storeWidth" />
      <el-table-column label="存放高mm" align="center" prop="storeHeight" />
      <el-table-column label="裸件重量g" align="center" prop="grossWeight" />
      <el-table-column label="包装后重量g" align="center" prop="packageWeight" />
      <el-table-column label="体积" align="center" prop="volume" />
      <el-table-column label="是否可销售" align="center" prop="isSale">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.no_and_yes" :value="scope.row.isSale"/>
        </template>
      </el-table-column>
      <el-table-column label="是否可采购" align="center" prop="isPurchase">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.no_and_yes" :value="scope.row.isPurchase"/>
        </template>
      </el-table-column>
      <el-table-column label="是否排放件" align="center" prop="isEmission">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.no_and_yes" :value="scope.row.isEmission"/>
        </template>
      </el-table-column>
      <el-table-column label="是否安全件" align="center" prop="isSafety">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.no_and_yes" :value="scope.row.isSafety"/>
        </template>
      </el-table-column>
      <el-table-column label="是否防盗件" align="center" prop="isAntiTheft">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.no_and_yes" :value="scope.row.isAntiTheft"/>
        </template>
      </el-table-column>
      <el-table-column label="是否认证件" align="center" prop="isCertified">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.no_and_yes" :value="scope.row.isCertified"/>
        </template>
      </el-table-column>
      <el-table-column label="是否航空禁运件" align="center" prop="isAirEmbargo">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.no_and_yes" :value="scope.row.isAirEmbargo"/>
        </template>
      </el-table-column>
      <el-table-column label="厂端id" align="center" prop="factoryId" />
      <el-table-column label="厂端名称" align="center" prop="factoryName" />
      <el-table-column label="经销商id" align="center" prop="dealerId" />
      <el-table-column label="销售店名称" align="center" prop="dealerName" />
<!--      <el-table-column label="经销商出库时间" align="center" prop="dealerLastShipmentTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.dealerLastShipmentTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="经销商入库时间" align="center" prop="dealerLastStorageTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dealerLastStorageTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="厂端出库时间" align="center" prop="factoryLastShipmentTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.factoryLastShipmentTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="厂端入库时间" align="center" prop="factoryLastStorageTime" width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span>{{ parseTime(scope.row.factoryLastStorageTime, '{y}-{m}-{d}') }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-edit"-->
<!--            @click="handleUpdate(scope.row)"-->
<!--            v-hasPermi="['part:inventory:edit']"-->
<!--          >修改</el-button>-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['part:inventory:remove']"
            v-show="scope.row.partStatus==0"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改零件库存信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<!--        <el-form-item label="店端/厂端的库存" prop="inventoryType">-->
<!--          <el-input v-model="form.inventoryType" placeholder="请输入店端/厂端的库存" />-->
<!--        </el-form-item>-->
        <el-form-item label="零件来源" prop="partSource">
          <el-select v-model="form.partSource" placeholder="请选择零件来源">
            <el-option
              v-for="dict in dict.type.part_source"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="零件编码" prop="partNo">
          <el-input v-model="form.partNo" placeholder="请输入零件编码(不输入，后台自动生成)" />
        </el-form-item>
        <el-form-item label="零件名称" prop="partName">
          <el-input v-model="form.partName" placeholder="请输入零件名称" />
        </el-form-item>
        <el-form-item label="零件类型" prop="partType">
          <el-select v-model="form.partType" placeholder="请选择零件类型">
            <el-option
              v-for="dict in dict.type.part_name"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="零件状态" prop="partStatus">
          <el-select v-model="form.partStatus" placeholder="请选择零件状态">
            <el-option
              v-for="dict in dict.type.part_status"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="网点单价" prop="outletPrice">
          <el-input v-model="form.outletPrice" placeholder="请输入网点单价（子公司向经销商售卖价）" />
        </el-form-item>
<!--        <el-form-item label="零售单价" prop="salePrice">-->
<!--          <el-input v-model="form.salePrice" placeholder="请输入零售单价（经销商向用户售卖价）" />-->
<!--        </el-form-item>-->
<!--        <el-form-item label="采购单价" prop="purchasePrice">-->
<!--          <el-input v-model="form.purchasePrice" placeholder="请输入采购单价(子公司向总部采购价）" />-->
<!--        </el-form-item>-->
        <el-form-item label="生效日期" prop="effectiveDate">
          <el-date-picker clearable
            v-model="form.effectiveDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择生效日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="截止日期" prop="expirationDate">
          <el-date-picker clearable
            v-model="form.expirationDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择截止日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="裸件长" prop="grossLength">
          <el-input v-model="form.grossLength" placeholder="请输入裸件长mm" />
        </el-form-item>
        <el-form-item label="裸件宽" prop="grossWidth">
          <el-input v-model="form.grossWidth" placeholder="请输入裸件宽mm" />
        </el-form-item>
        <el-form-item label="裸件高" prop="grossHeight">
          <el-input v-model="form.grossHeight" placeholder="请输入裸件高mm" />
        </el-form-item>
        <el-form-item label="包装长" prop="packageLength">
          <el-input v-model="form.packageLength" placeholder="请输入包装长mm" />
        </el-form-item>
        <el-form-item label="包装宽" prop="packageWidth">
          <el-input v-model="form.packageWidth" placeholder="请输入包装宽mm" />
        </el-form-item>
        <el-form-item label="包装高" prop="packageHeight">
          <el-input v-model="form.packageHeight" placeholder="请输入包装高mm" />
        </el-form-item>
        <el-form-item label="存放长" prop="storeLength">
          <el-input v-model="form.storeLength" placeholder="请输入存放长mm" />
        </el-form-item>
        <el-form-item label="存放宽" prop="storeWidth">
          <el-input v-model="form.storeWidth" placeholder="请输入存放宽mm" />
        </el-form-item>
        <el-form-item label="存放高" prop="storeHeight">
          <el-input v-model="form.storeHeight" placeholder="请输入存放高mm" />
        </el-form-item>
        <el-form-item label="裸件重量" prop="grossWeight">
          <el-input v-model="form.grossWeight" placeholder="请输入裸件重量g" />
        </el-form-item>
        <el-form-item label="包装重量" prop="packageWeight">
          <el-input v-model="form.packageWeight" placeholder="请输入包装后重量g" />
        </el-form-item>
        <el-form-item label="体积" prop="volume">
          <el-input v-model="form.volume" placeholder="请输入体积" />
        </el-form-item>
        <el-form-item label="是否销售" prop="isSale">
          <el-radio-group v-model="form.isSale">
            <el-radio
              v-for="dict in dict.type.no_and_yes"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否采购" prop="isPurchase">
          <el-radio-group v-model="form.isPurchase">
            <el-radio
              v-for="dict in dict.type.no_and_yes"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否排放" prop="isEmission">
          <el-radio-group v-model="form.isEmission">
            <el-radio
              v-for="dict in dict.type.no_and_yes"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否安全" prop="isSafety">
          <el-radio-group v-model="form.isSafety">
            <el-radio
              v-for="dict in dict.type.no_and_yes"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否防盗" prop="isAntiTheft">
          <el-radio-group v-model="form.isAntiTheft">
            <el-radio
              v-for="dict in dict.type.no_and_yes"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否认证" prop="isCertified">
          <el-radio-group v-model="form.isCertified">
            <el-radio
              v-for="dict in dict.type.no_and_yes"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="是否航空禁运件" prop="isAirEmbargo">
          <el-radio-group v-model="form.isAirEmbargo">
            <el-radio
              v-for="dict in dict.type.no_and_yes"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
<!--        <el-form-item label="经销商出库时间" prop="dealerLastShipmentTime">-->
<!--          <el-date-picker clearable-->
<!--            v-model="form.dealerLastShipmentTime"-->
<!--            type="date"-->
<!--            value-format="yyyy-MM-dd"-->
<!--            placeholder="经销商的零件最后一次出库时间">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
        <el-form-item label="经销商入库时间" prop="dealerLastStorageTime">
          <el-date-picker clearable
            v-model="form.dealerLastStorageTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="经销商的零件最后一次入库时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="厂端出库时间" prop="factoryLastShipmentTime">
          <el-date-picker clearable
            v-model="form.factoryLastShipmentTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="厂端的零件最后一次出库时间">
          </el-date-picker>
        </el-form-item>
<!--        <el-form-item label="厂端入库时间" prop="factoryLastStorageTime">-->
<!--          <el-date-picker clearable-->
<!--            v-model="form.factoryLastStorageTime"-->
<!--            type="date"-->
<!--            value-format="yyyy-MM-dd"-->
<!--            placeholder="厂端的零件最后一次入库时间">-->
<!--          </el-date-picker>-->
<!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInventory, getInventory, delInventory, addInventory, updateInventory } from "@/api/part/inventory";

export default {
  name: "Inventory",
  dicts: ['part_name', 'no_and_yes', 'part_status', 'part_source'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 零件库存信息表格数据
      inventoryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: null,
        inventoryType: null,
        partSource: null,
        partNo: null,
        partName: null,
        partType: null,
        partStatus: null,
        outletPrice: null,
        salePrice: null,
        purchasePrice: null,
        effectiveDate: null,
        expirationDate: null,
        grossLength: null,
        grossWidth: null,
        grossHeight: null,
        packageLength: null,
        packageWidth: null,
        packageHeight: null,
        storeLength: null,
        storeWidth: null,
        storeHeight: null,
        grossWeight: null,
        packageWeight: null,
        volume: null,
        isSale: null,
        isPurchase: null,
        isEmission: null,
        isSafety: null,
        isAntiTheft: null,
        isCertified: null,
        isAirEmbargo: null,
        factoryId: null,
        factoryName: null,
        dealerId: null,
        dealerName: null,
        dealerLastShipmentTime: null,
        dealerLastStorageTime: null,
        factoryLastShipmentTime: null,
        factoryLastStorageTime: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        partSource: [
          { required: true, message: "零件来源不能为空", trigger: "change" }
        ],
        // partNo: [
        //   { required: true, message: "零件编码不能为空", trigger: "blur" }
        // ],
        partName: [
          { required: true, message: "零件名称不能为空", trigger: "blur" }
        ],
        partType: [
          { required: true, message: "零件类型不能为空", trigger: "change" }
        ],
        partStatus: [
          { required: true, message: "零件状态不能为空", trigger: "change" }
        ],
        outletPrice: [
          { required: true, message: "网点单价不能为空（子公司向经销商售卖价）", trigger: "blur" }
        ],
        // salePrice: [
        //   { required: true, message: "零售单价不能为空（经销商向用户售卖价）", trigger: "blur" }
        // ],
        // purchasePrice: [
        //   { required: true, message: "采购单价(子公司向总部采购价）不能为空", trigger: "blur" }
        // ],
        effectiveDate: [
          { required: true, message: "生效日期不能为空", trigger: "blur" }
        ],
        expirationDate: [
          { required: true, message: "截止日期不能为空", trigger: "blur" }
        ],
        grossLength: [
          { required: true, message: "裸件长mm不能为空", trigger: "blur" }
        ],
        grossWidth: [
          { required: true, message: "裸件宽mm不能为空", trigger: "blur" }
        ],
        grossHeight: [
          { required: true, message: "裸件高mm不能为空", trigger: "blur" }
        ],
        packageLength: [
          { required: true, message: "包装长mm不能为空", trigger: "blur" }
        ],
        packageWidth: [
          { required: true, message: "包装宽mm不能为空", trigger: "blur" }
        ],
        packageHeight: [
          { required: true, message: "包装高mm不能为空", trigger: "blur" }
        ],
        storeLength: [
          { required: true, message: "存放长mm不能为空", trigger: "blur" }
        ],
        storeWidth: [
          { required: true, message: "存放宽mm不能为空", trigger: "blur" }
        ],
        storeHeight: [
          { required: true, message: "存放高mm不能为空", trigger: "blur" }
        ],
        grossWeight: [
          { required: true, message: "裸件重量g不能为空", trigger: "blur" }
        ],
        packageWeight: [
          { required: true, message: "包装后重量g不能为空", trigger: "blur" }
        ],
        volume: [
          { required: true, message: "体积不能为空", trigger: "blur" }
        ],
        isSale: [
          { required: true, message: "是否可销售不能为空", trigger: "change" }
        ],
        isPurchase: [
          { required: true, message: "是否可采购不能为空", trigger: "change" }
        ],
        isEmission: [
          { required: true, message: "是否排放件不能为空", trigger: "change" }
        ],
        isSafety: [
          { required: true, message: "是否安全件不能为空", trigger: "change" }
        ],
        isAntiTheft: [
          { required: true, message: "是否防盗件不能为空", trigger: "change" }
        ],
        isCertified: [
          { required: true, message: "是否认证件不能为空", trigger: "change" }
        ],
        isAirEmbargo: [
          { required: true, message: "是否航空禁运件不能为空", trigger: "change" }
        ],
        // dealerLastShipmentTime: [
        //   { required: true, message: "经销商的零件最后一次出库时间不能为空", trigger: "blur" }
        // ],
        // dealerLastStorageTime: [
        //   { required: true, message: "经销商的零件最后一次入库时间不能为空", trigger: "blur" }
        // ],
        factoryLastShipmentTime: [
          { required: true, message: "厂端的零件最后一次出库时间不能为空", trigger: "blur" }
        ],
        factoryLastStorageTime: [
          { required: true, message: "厂端的零件最后一次入库时间不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询零件库存信息列表 */
    getList() {
      this.loading = true;
      listInventory(this.queryParams).then(response => {
        this.inventoryList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        inventoryType: null,
        partSource: null,
        partNo: null,
        partName: null,
        partType: null,
        partStatus: null,
        outletPrice: null,
        salePrice: null,
        purchasePrice: null,
        effectiveDate: null,
        expirationDate: null,
        grossLength: null,
        grossWidth: null,
        grossHeight: null,
        packageLength: null,
        packageWidth: null,
        packageHeight: null,
        storeLength: null,
        storeWidth: null,
        storeHeight: null,
        grossWeight: null,
        packageWeight: null,
        volume: null,
        isSale: null,
        isPurchase: null,
        isEmission: null,
        isSafety: null,
        isAntiTheft: null,
        isCertified: null,
        isAirEmbargo: null,
        factoryId: null,
        factoryName: null,
        dealerId: null,
        dealerName: null,
        dealerLastShipmentTime: null,
        dealerLastStorageTime: null,
        factoryLastShipmentTime: null,
        factoryLastStorageTime: null,
        auditorId: null,
        auditorName: null,
        auditorTime: null,
        createTime: null,
        updateTime: null,
        createBy: null,
        updateBy: null,
        createUserName: null,
        updateUserName: null,
        version: null,
        deleteFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加零件库存信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getInventory(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改零件库存信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateInventory(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInventory(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      if (this.$store.state.user.name.charAt(0)!='C'){
        this.$message.error('只有厂端才有权限删除！');
        return;
      }
      this.$modal.confirm('是否确认删除零件库存信息编号为"' + ids + '"的数据项？').then(function() {
        return delInventory(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('part/inventory/export', {
        ...this.queryParams
      }, `inventory_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
